@@ -7,7 +7,7 @@ describe Agents::MqttAgent do |
||
7 | 7 |
before :each do |
8 | 8 |
@error_log = StringIO.new |
9 | 9 |
|
10 |
- @server = MQTT::FakeServer.new(41234, '127.0.0.1') |
|
10 |
+ @server = MQTT::FakeServer.new('127.0.0.1') |
|
11 | 11 |
@server.logger = Logger.new(@error_log) |
12 | 12 |
@server.logger.level = Logger::DEBUG |
13 | 13 |
@server.start |
@@ -35,8 +35,7 @@ class MQTT::FakeServer |
||
35 | 35 |
# |
36 | 36 |
# If no port is given, bind to a random port number |
37 | 37 |
# If no bind address is given, bind to localhost |
38 |
- def initialize(port=nil, bind_address='127.0.0.1') |
|
39 |
- @port = port |
|
38 |
+ def initialize(bind_address='127.0.0.1') |
|
40 | 39 |
@address = bind_address |
41 | 40 |
end |
42 | 41 |
|
@@ -47,7 +46,7 @@ class MQTT::FakeServer |
||
47 | 46 |
|
48 | 47 |
# Start the thread and open the socket that will process client connections |
49 | 48 |
def start |
50 |
- @socket ||= TCPServer.new(@address, @port) |
|
49 |
+ @socket ||= TCPServer.new(@address, 0) |
|
51 | 50 |
@address = @socket.addr[3] |
52 | 51 |
@port = @socket.addr[1] |
53 | 52 |
@thread ||= Thread.new do |